<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>组件</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      header{
        height: 100px;
        background: #aef;
      }
      main{
        height: 400px;
        background: #cea;
      }
      footer{
        height: 100px;
        background: #fcb;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">

      //函数式组件 用函数封装虚拟 DOM 对象
      function Top(){ //组件名称首字母一定要大写
        return <header></header>;
      }

      function Content(){
        return <main></main>
      }

      function Bottom(){
        return <footer></footer>
      }

      //创建虚拟 DOM 对象
      // <Top></Top>  =>  React.createElement(Top)  =>  内部找到同名的函数 => 然后调用该函数, 获得虚拟 DOM 对象, 最终再渲染
      function App(){
        return <div>
            <Top></Top>
            <Content />
            <Bottom />
        </div>
      }

      //渲染
      ReactDOM.render(<App />, document.querySelector('#root'));

      // <Button>xx</Button>
    </script>
  </body>
</html>
